package com.yanqu.road.entity.activity.washe.config;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.utils.string.StringUtils;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_n_washepvp_skill")
public class WasheSkillConfig {

    private int activityId;
    private int skillId;
    private String price;
    private String skillParam;
    private String skillName;
    private String skillDesc;
    private int itemId;
    private long maxTime;
    private int open;

    private List<Long> skillParamList;
    private Map<Integer, Long> priceMap;

    // =======================================

    public boolean isOpen() {
        return open == 1;
    }

    public boolean isFree() {
        return priceMap.isEmpty();
    }

    public void init() {
        skillParamList = StringUtils.stringToLongList(skillParam, "\\|");

        Map<Integer, Long> tmp = new ConcurrentHashMap<>();
        if (!"0".equals(price)) {
            for (String s : price.split("\\|")) {
                String[] split = s.split(",");
                tmp.put(Integer.valueOf(split[1]), Long.valueOf(split[0]));
            }
        }
        priceMap = tmp;
    }

    // =======================================

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getSkillId() {
        return skillId;
    }

    public void setSkillId(int skillId) {
        this.skillId = skillId;
    }

    public String getSkillParam() {
        return skillParam;
    }

    public void setSkillParam(String skillParam) {
        this.skillParam = skillParam;
    }

    public String getSkillName() {
        return skillName;
    }

    public void setSkillName(String skillName) {
        this.skillName = skillName;
    }

    public String getSkillDesc() {
        return skillDesc;
    }

    public void setSkillDesc(String skillDesc) {
        this.skillDesc = skillDesc;
    }

    public int getItemId() {
        return itemId;
    }

    public void setItemId(int itemId) {
        this.itemId = itemId;
    }

    public long getMaxTime() {
        return maxTime;
    }

    public void setMaxTime(long maxTime) {
        this.maxTime = maxTime;
    }

    public List<Long> getSkillParamList() {
        return skillParamList;
    }

    public void setSkillParamList(List<Long> skillParamList) {
        this.skillParamList = skillParamList;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public Map<Integer, Long> getPriceMap() {
        return priceMap;
    }

    public void setPriceMap(Map<Integer, Long> priceMap) {
        this.priceMap = priceMap;
    }

    public String getPrice() {
        return price;
    }

    public int getOpen() {
        return open;
    }

    public void setOpen(int open) {
        this.open = open;
    }
}
